<?php

namespace app\index\model;
use think\Db;
use think\Model;
use think\Session;
use think\Cookie;

class Log extends Model
{
    protected $table = 'xt_log_a';
    //增加日志记录
    //$data=array()
    public function AddLog($log,$show='',$ybid='',$sql=''){
        $user = Session::get('userinfo.username');
        if(empty($user)){
            $user = Cookie::get('userinfo');
        }
        $data = array('user'=>$user,'log'=>$log,'ybid'=>$ybid,'createdate'=> date('Y-m-d H:i:s', time()),'show'=>$show,'sql'=>$sql);
        $res = Db::table('xt_log_a')->data($data)->insert();
    }
    //获取日志记录
    public function GetLog(){
        return $res = Db::table('xt_log_a')->where('show', 1)->order('id desc')->paginate(10);
    }

    public function layGetLog(){
        return $res = Db::table('xt_log_a')->select();
    }
}